package com.example.demo.controller;


import com.alipay.api.AlipayApiException;
import com.alipay.api.request.AlipayTradePrecreateRequest;
import com.alipay.api.response.AlipayToolsFileUploadResponse;
import com.alipay.api.response.AlipayTradePrecreateResponse;
import com.example.demo.pay.PayNeedData;

import com.example.demo.utils.pay.WxPay;
import com.example.demo.utils.pay.ZfbPay;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;

@RestController
//@Controller
@RequestMapping("/zfbPay")

public class ZfbPayController {

	private WxPay wxPay;
	private ZfbPay zfbPay;
	public ZfbPayController(WxPay wxPay, ZfbPay zfbPay) {
		this.wxPay = wxPay;
		this.zfbPay = zfbPay;
	}

	@CrossOrigin
	@GetMapping
	public String pay( HttpServletResponse resp) throws AlipayApiException {
		PayNeedData payNeedData = new PayNeedData();
		payNeedData.setPrice(0.01);
		payNeedData.setOrderId(System.currentTimeMillis()+"");
		return  zfbPay.pay(payNeedData);

	}

	@GetMapping("/success")
	public String success(){
		System.out.println("支付成功");
		return "success";
	}

}
